import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/customer_model.dart';

CustomerModel $CustomerModelFromJson(Map<String, dynamic> json) {
  final CustomerModel customerModel = CustomerModel();
  final int? uid = jsonConvert.convert<int>(json['uid']);
  if (uid != null) {
    customerModel.uid = uid;
  }
  final String? mobile = jsonConvert.convert<String>(json['mobile']);
  if (mobile != null) {
    customerModel.mobile = mobile;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    customerModel.avatar = avatar;
  }
  final String? nickname = jsonConvert.convert<String>(json['nickname']);
  if (nickname != null) {
    customerModel.nickname = nickname;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    customerModel.createdAt = createdAt;
  }
  final int? orderCount = jsonConvert.convert<int>(json['order_count']);
  if (orderCount != null) {
    customerModel.orderCount = orderCount;
  }
  final double? orderSumPayPrice = jsonConvert.convert<double>(json['order_sum_pay_price']);
  if (orderSumPayPrice != null) {
    customerModel.orderSumPayPrice = orderSumPayPrice;
  }
  return customerModel;
}

Map<String, dynamic> $CustomerModelToJson(CustomerModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['uid'] = entity.uid;
  data['mobile'] = entity.mobile;
  data['avatar'] = entity.avatar;
  data['nickname'] = entity.nickname;
  data['created_at'] = entity.createdAt;
  data['order_count'] = entity.orderCount;
  data['order_sum_pay_price'] = entity.orderSumPayPrice;
  return data;
}

extension CustomerModelExtension on CustomerModel {
  CustomerModel copyWith({
    int? uid,
    String? mobile,
    String? avatar,
    String? nickname,
    String? createdAt,
    int? orderCount,
    double? orderSumPayPrice,
  }) {
    return CustomerModel()
      ..uid = uid ?? this.uid
      ..mobile = mobile ?? this.mobile
      ..avatar = avatar ?? this.avatar
      ..nickname = nickname ?? this.nickname
      ..createdAt = createdAt ?? this.createdAt
      ..orderCount = orderCount ?? this.orderCount
      ..orderSumPayPrice = orderSumPayPrice ?? this.orderSumPayPrice;
  }
}